package com.jyw.business.obstacles.domain.vo.web;

import com.alibaba.fastjson2.JSONObject;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

import static com.jyw.business.obstacles.enums.WebSocketCodeEnum.*;

/**
 * @author 沈峻
 * @ClassName ServerDeskWebSocketVO
 * @Description 返回对象
 * @Date 2023/8/21 16:36
 **/
@Data
@NoArgsConstructor
public class ServerDeskWebSocketVO {
    /**
     * 返回数据
     */
    private Object body;
    /**
     * 消息类型
     */
    private String type;
    /**
     * 事件编码
     */
    private long code;
    /**
     * 通知信息
     */
    private String msg;

    public ServerDeskWebSocketVO(Object body, String type, long code, String msg) {
        this.body = body;
        this.type = type;
        this.code = code;
        this.msg = msg;
    }

    /**
     * 封装心跳信息
     * @return
     */
    public static String ofHeartBeat(){
        return JSONObject.toJSONString(new ServerDeskWebSocketVO(null, HEART_BEAT.name(),HEART_BEAT.getCode(),HEART_BEAT.getMsg()));
    }


    /**
     * 封装弹屏故障信息
     * @param busOrderInfoWebDto
     * @return
     */
    public static String ofFaultInfo(OrderInfoWebVO busOrderInfoWebDto) {
        return JSONObject.toJSONString(new ServerDeskWebSocketVO(busOrderInfoWebDto, FAULT_INFO_SOCKET.name(),FAULT_INFO_SOCKET.getCode(),FAULT_INFO_SOCKET.getMsg()));
    }

    /**
     * 封装坐席变更信息
     * @param seatCache
     * @return
     */
    public static String ofSeatInfo(Map<String, Long> seatCache) {
        return JSONObject.toJSONString(new ServerDeskWebSocketVO(seatCache,SEAT_INFO_SUCCESS.name(),SEAT_INFO_SUCCESS.getCode(),SEAT_INFO_SUCCESS.getMsg()));
    }

    /**
     * 发送当前坐席信息
     * @param seatCache
     * @return
     */
    public static String ofSeatCurrent(Map<String, Long> seatCache) {
        return JSONObject.toJSONString(new ServerDeskWebSocketVO(seatCache, SEAT_CURRENT.name(), SEAT_CURRENT.getCode(), SEAT_CURRENT.getMsg()));
    }

    /**
     * 发送报修挂机信息
     * @param busOrderInfoWebDto
     * @return
     */
    public static String ofHangUp(OrderInfoWebVO busOrderInfoWebDto) {
        return JSONObject.toJSONString(new ServerDeskWebSocketVO(busOrderInfoWebDto, HANG_UP.name(),HANG_UP.getCode(),HANG_UP.getMsg()));
    }

    /**
     * 发送报修接听信息
     * @param busOrderInfoWebDto
     * @return
     */
    public static String ofAnswer(OrderInfoWebVO busOrderInfoWebDto) {
        return JSONObject.toJSONString(new ServerDeskWebSocketVO(busOrderInfoWebDto, ANSWER.name(),ANSWER.getCode(),ANSWER.getMsg()));
    }
}
